﻿namespace BM.Tools.WebControls.MForm.Generator.Templates
{
    using System.Collections.Generic;    
    using System.Web.UI;

    /// <summary>
    /// This class is used to merge different Templates into one.
    /// </summary>
    public class MergedTemplate : ITemplate
    {        
        /// <summary>
        /// Initializes a new instance of the <see cref="MergedTemplate"/> class. 
        /// </summary>
        /// <param name="templates">
        /// The Templates.
        /// </param>
        public MergedTemplate(IEnumerable<ITemplate> templates)
        {
            Templates = templates;
        }

        /// <summary>
        /// Gets Templates.
        /// </summary>
        /// <value>
        /// The templates that are merged.
        /// </value>
        public IEnumerable<ITemplate> Templates
        {
            get;
            private set;
        }

        /// <summary>
        /// Instantiates the merged templates in the specified container.
        /// </summary>
        /// <param name="container">
        /// The container.
        /// </param>
        public void InstantiateIn(Control container)
        {
            foreach (var template in Templates)
            {
                template.InstantiateIn(container);
            }
        }
    }
}